package com.tangzx.builder.abc.string;

import macromedia.asc.embedding.avmplus.ActionBlockConstants;
import com.tangzx.builder.abc.AbcCPool;
import com.tangzx.builder.abc.AbcElement;
/**
 * MultiName
 * <br>name + ns_set
 * @author tangzhixu
 *
 */
public class MultiName extends AbcElement{
	public int kind = 0;
    public int[] params;
    
    public MultiName(int kind, int[] params)
    {
    	this.kind = kind;
    	this.params = params;
    }
    
    @Override
    public void setCpool(AbcCPool pool) {
    	super.setCpool(pool);
    	
    	//if (kind == ActionBlockConstants.CONSTANT_MultinameA)
    	AbcString as = null;
    	NamespaceSet nss = null;
    	switch(kind)
    	{
    	case ActionBlockConstants.CONSTANT_Multiname:
    		as = pool.getString(params[0]);
    		nss = cpool.getNamespaceSet(params[1]);
    		
    		if (nss.size() > 1)
    		{
    			as.vo.setCanNotMix();
    			//System.out.println("MULTINAME:" + as);
    		}
    		
    		break;
    	case ActionBlockConstants.CONSTANT_MultinameA:
    	case ActionBlockConstants.CONSTANT_MultinameLA:
    		as = pool.getString(params[0]);
    		as.vo.setCanNotMix();
    		break;
    	}
    }
    
    public int getKind()
    {
    	return this.kind;
    }
    
    public int[] getParams()
    {
    	return this.params;
    }
    
    public AbcString getName() {
    	return cpool.getString(params[0]);
    }
    
    @Override
    public String toString() {
    	String v = "[Multiname:[" + getName() + "]]";
    	return v;
    }
}
